<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./serviceConfig.xhtml">

            <ui:define name="tabContent">
                <h:form>
                    <p:panel>
                        Giấc mơ*     <p:inputText value="#{moConfigBean.selected.content}"
                                                  required="true" requiredMessage="Bạn chưa nhập giấc mơ"/>
                        Số trả về* 
                        <p:inputText value="#{moConfigBean.selected.code}"
                                     required="true" requiredMessage="Bạn chưa điền số trả về"/>

                        <h:panelGrid columns="5">
                            <p:commandButton ajax="false" value="Thêm mới" rendered="#{!moConfigBean.edit}" action="#{moConfigBean.create()}"/>
                            <p:commandButton ajax="false" value="Cập nhật" rendered="#{moConfigBean.edit}" action="#{moConfigBean.edit()}"/>
                            <p:commandButton ajax="false" value="Hủy bỏ" immediate="true" action="#{moConfigBean.resetToCreateForm()}"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>
                <br/>
                <h:form>
                    <p:dataTable id="table" value="#{moConfigBean.list}" var="item" paginator="#{moConfigBean.list.size() >20}" rows="20" 
                                 selection="#{moConfigBean.selectedList}" selectionMode="multiple">

                        <f:facet name="header">  
                            <div align="left">
                                <p:menuButton value="Xử lý bản ghi được chọn">  
                                    <p:menuitem ajax="false" value="Chỉnh sửa" icon="ui-icon ui-icon-pencil" action="#{moConfigBean.prepareEdit()}"/>
                                    <p:menuitem value="Xóa" icon="ui-icon ui-icon-close" onclick="cauDeleteConfirm.show()" />   
                                </p:menuButton> 
                            </div>
                        </f:facet> 

                        <f:facet name="footer">  
                            <div align="left">
                                <p:menuButton value="Xử lý bản ghi được chọn">  
                                    <p:menuitem ajax="false" value="Chỉnh sửa" icon="ui-icon ui-icon-pencil" action="#{moConfigBean.prepareEdit()}"/>
                                    <p:menuitem value="Xóa" icon="ui-icon ui-icon-close" onclick="cauDeleteConfirm.show()" />   
                                </p:menuButton> 
                            </div>
                        </f:facet> 

                        <p:column headerText="Đầu số" sortBy="#{item.content}" filterBy="#{item.content}" filterMatchMode="contains">
                            #{item.content}
                        </p:column>
                        <p:column headerText="ND tin nhắn lên" sortBy="#{item.code}"  filterBy="#{item.code}" filterMatchMode="contains">
                            #{item.code}
                        </p:column>
                    </p:dataTable>

                    <p:confirmDialog modal="true" message="Bạn muốn xóa các bản ghi đã chọn?"  
                                     hideEffect="explode"  
                                     header="Xác nhận" severity="alert" widgetVar="cauDeleteConfirm">  

                        <p:commandButton update="table" value="Có" oncomplete="cauDeleteConfirm.hide()"  
                                         action="#{moConfigBean.remove()}"/>
                        <p:commandButton value="Không" onclick="cauDeleteConfirm.hide()" type="button" />   

                    </p:confirmDialog> 

                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>

